home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / RANDOM < prev    next >
Encoding:
Text File  |  1985-12-14  |  1.1 KB  |  32 lines

  1. ;-------------------------random routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 175
  4. ;
  5. ; NAME RANDOM
  6. ; ROUTINE FOR PSEUDO-RANDOM NUMBER GENERATOR
  7. ;
  8. ; FUNCTION: This routine generates pseudo-random numbers bewteen0 and 1.
  9. ; The numbers are stored in 16-bit binary fixed-point notation with the
  10. ; binary point on the extreme left.
  11. ; INPUT: Upon entry the variabl,e SEED contains a seed value.
  12. ; OUTPUT: Upon exit the seed is updated and the CX register contains a
  13. ; pseudo-random number.
  14. ; REGISTERS USED:  Only CX is modified.
  15. ; SEGMENTS REFERENCED:  pon entry the data segment contains the variable
  16. ;    SEED.
  17. ; ROUTINES CALLED:  None
  18. ; SPECIAL NOTES: None
  19. ;
  20. random    proc    far
  21. ;
  22.     mov    cx,seed        ;get the seed
  23.     add    cx,9248h    ; add random pattern
  24.     ror    cx,1        ; rotate
  25.     ror    cx,1        ; three
  26.     ror    cx,1        ; times.
  27.     mov    seed,cx        ; put it back
  28.     ret            ; return
  29. ;
  30. random    endp
  31. ;-------------------------random routine ends---------------------------+
  32.